

#ifndef UD_DBXUTIL_H
#define UD_DBXUTIL_H 1

#include "zacadstrc.h"
#include "zadesk.h"
#include "zadsdef.h"
#include "zdbidar.h"
#include "zdbid.h"
#include "zacutmem.h"

#ifdef _ZSOFT_WINDOWS_
#include "windows.h"
#endif

#pragma pack (push, 8)

class UcGeMatrix3d;
class UcDbObject;
class UcDbOle2Frame;
class UcCmColor;
class UcDbViewport;
class UcDbBlockTableRecord;

bool    ucdbWcs2Ucs(zds_point p, zds_point q, bool vec);
bool    ucdbWcs2Ecs(zds_point p, zds_point q, zds_point norm, bool vec);
bool    ucdbUcs2Wcs(zds_point p, zds_point q, bool vec);
bool    ucdbUcs2Ecs(zds_point p, zds_point q, zds_point norm, bool vec);
bool    ucdbEcs2Wcs(zds_point p, zds_point q, zds_point norm, bool vec);
bool    ucdbEcs2Ucs(zds_point p, zds_point q, zds_point norm, bool vec);

UcGeVector3d     ucsXDir();
UcGeVector3d     ucsYDir();
void			 ucsNormalVector(UcGeVector3d& ucsNormalVec);
UcDbObjectId      ucdbGetCurVportTableRecordId(UcDbDatabase* pDb);
UcDbObjectId      ucdbGetCurVportId(UcDbDatabase* pDb);
Ucad::ErrorStatus ucdbGetProxyInfo(UcDbObject *pObj, ZTCHAR*& dxfName,
                                   ZTCHAR*& className, ZTCHAR*& appName);
bool    ucdbUcsMatrix(UcGeMatrix3d& mat, UcDbDatabase * pDb = NULL);

Ucad::ErrorStatus ucdbGetExtnames(bool &value, UcDbDatabase *pDb);
Ucad::ErrorStatus ucdbSetExtnames(UcDbDatabase *pDb, bool value);

#ifdef _ZSOFT_WINDOWS_
bool ucdbGetPreviewBitmapFromDwg(const ZTCHAR* pszDwgfilename,
                                 HBITMAP* pPreviewBmp,
                                 HPALETTE* pRetPal);
#endif

const ZTCHAR* ucdbGetReservedString(UcDb::reservedStringEnumType reservedType,
    bool bGetLocalized = true);
const ZTCHAR* ucdbXlateReservedString(const ZTCHAR* strSource,
    bool bGetLocalized = true);
bool ucdbIsReservedString(const ZTCHAR* strString,
    UcDb::reservedStringEnumType reservedType);

bool ucdbPSLayoutAnnoAllVisible(UcDbObjectId viewportEntityId);
bool ucdbPSLayoutAnnoAllVisible(UcDbViewport* pVport);

Ucad::ErrorStatus ucdbGetUnitsConversion (UcDb::UnitsValue from,
                                          UcDb::UnitsValue to,
                                          double& conversionFactor);

bool ZSOFT_STDCALL ucdbDwkFileExists(const ZTCHAR *pszFileName);

int ZSOFT_STDCALL ucdbQueueForRegen(const UcDbObjectId *pIdArray,
                                    int nNumIds);

UcDbObjectId  ucdbGetDynDimStyleId( UcDbDatabase* pDb = NULL );

Ucad::ErrorStatus
ucdbCreateViewByViewport( UcDbDatabase *pDb,
                          UcDbObjectId viewportId, 
                          const ZTCHAR* name,
                          const ZTCHAR* categoryName,
                          UcDbObjectId labelBlockId,
                          UcDbObjectId& view);

Ucad::ErrorStatus
ucdbOleHitTest(const UcDbOle2Frame* pOleEnt,     
               const UcGePoint3d&  wvpt, 
               const UcGeVector3d& wvwdir);

Ucad::ErrorStatus
ucdbOleGetRotationMatrix(const UcDbOle2Frame* pOleEnt,
                         UcGeMatrix3d& rotMat);

Ucad::ErrorStatus
ucdbOleGetOriginalWidthHeight(const UcDbOle2Frame* pOleEnt,
                              double& width, 
                              double& height);

Ucad::ErrorStatus
ucdbOleSetOriginalWidthHeight(const UcDbOle2Frame* pOleEnt,
                              const double width, 
                              const double height);

Ucad::ErrorStatus
ucdbOleGetSelectedFontName(const UcDbOle2Frame* pOleEnt,
                           ZTCHAR*& fontName);

Ucad::ErrorStatus
ucdbOleSetSelectedFontName(const UcDbOle2Frame* pOleEnt,
                           const ZTCHAR* fontName);

Ucad::ErrorStatus
ucdbOleGetSelectedFontPointSize(const UcDbOle2Frame* pOleEnt,
                                int& pointSize);

Ucad::ErrorStatus
ucdbOleSetSelectedFontPointSize(const UcDbOle2Frame* pOleEnt,
                                const int pointSize);

Ucad::ErrorStatus
ucdbOleGetSelectedTextSizeInUcadUnits(const UcDbOle2Frame* pOleEnt,
                                      double& sizeInUcadUnits);

Ucad::ErrorStatus
ucdbOleSetSelectedTextSizeInUcadUnits(const UcDbOle2Frame* pOleEnt,
                                      const double sizeInUcadUnits);

Ucad::ErrorStatus
ucdbOleGetOriginalSelectedFontName(const UcDbOle2Frame* pOleEnt,
                                   ZTCHAR*& fontName);

Ucad::ErrorStatus
ucdbOleSetOriginalSelectedFontName(const UcDbOle2Frame* pOleEnt,
                                   const ZTCHAR* fontName);

Ucad::ErrorStatus
ucdbOleGetOriginalSelectedFontPointSize(const UcDbOle2Frame* pOleEnt,
                                        int& pointSize);

Ucad::ErrorStatus
ucdbOleSetOriginalSelectedFontPointSize(const UcDbOle2Frame* pOleEnt,
                                        const int pointSize);

Ucad::ErrorStatus
ucdbOleGetOriginalSelectedTextSizeInUcadUnits(const UcDbOle2Frame* pOleEnt,
                                              double& sizeInUcadUnits);

Ucad::ErrorStatus
ucdbOleSetOriginalSelectedTextSizeInUcadUnits(const UcDbOle2Frame* pOleEnt,
                                              const double sizeInUcadUnits);

bool 
ucdbGetDimTextBackground(UcDbObject *pObj, 
                         int& bgFlag, 
                         UcCmColor& bgColor);

bool 
ucdbSetDimTextBackground(UcDbObject *pObj, 
                         int bgFlag, 
                         UcCmColor* pBgColor,
                         bool autoClearOverride = true);

bool 
ucdbGetDimExtensionLength(UcDbObject *pObj, 
						  double& fValue);

bool 
ucdbSetDimExtensionLength(UcDbObject *pObj, 
						  double fValue,
						  bool autoClearOverride = true);

bool 
ucdbGetFixedLengthExtLineEnabled(UcDbObject *pObj,
								 int& nValue);

bool 
ucdbSetFixedLengthExtLineEnabled(UcDbObject *pObj, 
								 int nValue, 
								 bool autoClearOverride=true);

bool 
ucdbGetArcLengthSymbolPlacement(UcDbObject *pObj,
								int& nValue);

bool 
ucdbSetArcLengthSymbolPlacement(UcDbObject *pObj, 
								int nValue,
								bool autoClearOverride = true);
                          
bool 
ucdbGetDimLineLinetype(UcDbObject *pObj,
					   UcDbObjectId& oidValue);

bool 
ucdbSetDimLineLinetype(UcDbObject *pObj,
					   UcDbObjectId oidValue,
					   bool autoClearOverride = true);

bool 
ucdbGetDimExt1Linetype(UcDbObject *pObj,
					   UcDbObjectId& oidValue);

bool 
ucdbSetDimExt1Linetype(UcDbObject *pObj,
					   UcDbObjectId oidValue,
					   bool autoClearOverride = true);

bool 
ucdbGetDimExt2Linetype(UcDbObject *pObj,
					   UcDbObjectId& oidValue);

bool 
ucdbSetDimExt2Linetype(UcDbObject *pObj,
					   UcDbObjectId oidValue,
					   bool autoClearOverride = true);

bool 
ucdbGetLargeRadDimJogAngle(UcDbObject *pObj,
						   double& fJogAngle);

bool 
ucdbSetLargeRadDimJogAngle(UcDbObject *pObj, 
						   double fJogAngle,
						   bool autoClearOverride = true);

bool 
ucdbGetDimFlipArrow(UcDbObject *pObj,
					int& nValue);
 
bool 
ucdbSetDimFlipArrow(UcDbObject *pObj, 
					int nValue,
					bool autoClearOverride = true);

bool 
ucdbGetDimFlipArrowWhich(UcDbObject *pObj,
						 int& nValue);

bool 
ucdbSetDimFlipArrowWhich(UcDbObject *pObj, 
						 int nValue,
						 bool autoClearOverride = true);

bool ucdbGetExemptCheckFlag(UcDbObject *pObj, int& bitFlags);

bool ucdbSetExemptCheckFlag(UcDbObject *pObj, int bitFlags);

bool
ucdbGetDimJogSymbolSize(UcDbObject *pObj,
                        int& dimJagFlag,
                        double& dimJagSize);
bool
ucdbSetDimJogSymbolSize(UcDbObject *pObj,
                        int dimJagFlag,
                        const double dimJagSize,
                        bool autoClearOverride = true);
bool
ucdbGetDimJogSymbolPosition(UcDbObject *pObj,
                        int& dimJagFlag,
                        UcGePoint3d& pos);
bool
ucdbSetDimJogSymbolPosition(UcDbObject *pObj,
                        int& dimJagFlag,
                        const UcGePoint3d& pos,
                        bool autoClearOverride = true);

bool
ucdbGetRadialExtensionAngles(UcDbObject *pObj,
                             int& dimExtFlag,
                             double& dimExtAng1,
                             double& dimExtAng2);

bool
ucdbSetRadialExtensionAngles(UcDbObject *pObj,
                             int dimExtFlag,
                             double dimExtAng1,
                             double dimExtAng2);

bool
ucdbGetDimAngExtOn(UcDbObject *pObj,
                             int& dimExtFlag);

bool
ucdbSetDimAngExtOn(UcDbObject *pObj,
                             int dimExtFlag);

bool
ucdbGetDimTolAlign(UcDbObject *pObj,
                             int& dimTolAlignFlag);

bool
ucdbSetDimTolAlign(UcDbObject *pObj,
                             int dimTolAlignFlag,
                             bool autoClearOverride = true);
bool
ucdbGetDimBreakSize(UcDbObject *pObj,
                    double& dimBreakSize);
bool
ucdbSetDimBreakSize(UcDbObject *pObj,
                    double dimBreakSize,
                    bool autoClearOverride = true);

UcDbObjectId ucdbGetViewportVisualStyle();
Ucad::ErrorStatus ucdbSetViewportVisualStyle(UcDbObjectId visualStyleId);

Ucad::ErrorStatus ucdbForceTextAdjust(const UcDbObjectIdArray& objIds);

bool ucdbIsInLongTransaction(UcDbObjectId id);

Ucad::ErrorStatus ucdbSwapBlockEntities(UcDbBlockTableRecord* pBlock1, UcDbBlockTableRecord* pBlock2);

#pragma pack (pop)
#endif 
